//
//  HelloWorldLayer.m
//  Eliminator
//
//  Created by Rocky on 12-8-28.
//  Copyright __MyCompanyName__ 2012年. All rights reserved.
//


// Import the interfaces
#import "HelloWorldLayer.h"

// Needed to obtain the Navigation Controller
#import "AppDelegate.h"

#pragma mark - HelloWorldLayer

// HelloWorldLayer implementation
@implementation HelloWorldLayer

// on "init" you need to initialize your instance
-(id) init
{
	// always call "super" init
	// Apple recommends to re-assign "self" with the "super's" return value
	if( (self=[super init]) ) {
		
		// create and initialize a Label
		CCLabelTTF *label = [CCLabelTTF labelWithString:@"消去之王" fontName:@"Marker Felt" fontSize:64];

		// ask director for the window size
		CGSize size = [[CCDirector sharedDirector] winSize];
	
		// position the label on the center of the screen
		label.position =  ccp( size.width /2 , size.height/2 + 100);
		
		// add the label as a child to this Layer
		[self addChild: label];		
		
	
        // 菜单
		// Default font size will be 28 points.
		[CCMenuItemFont setFontSize:28];		

		CCMenuItem *newGameItem = [CCMenuItemFont itemWithString:@"新游戏" block:^(id sender) {
            DLog(@"new game");
		}];

		CCMenuItem *continueItem = [CCMenuItemFont itemWithString:@"继续" block:^(id sender) {			
			DLog(@"continue ");
		}];
		
		CCMenu *menu = [CCMenu menuWithItems:newGameItem, continueItem, nil];
		
		[menu alignItemsVerticallyWithPadding:20.0f];
		[menu setPosition:ccp( size.width/2, size.height/2)];
		
		// Add the menu to the layer
		[self addChild:menu];
        
        CCSprite *iconSprite = [CCSprite spriteWithFile:@"Icon.png"];
        iconSprite.position = CGPointMake(size.width / 2, 40);
        [self addChild:iconSprite];
        
        id flipX = [CCOrbitCamera actionWithDuration:1.3 radius:1 deltaRadius:0 angleZ:0 deltaAngleZ:360.0 angleX:0 deltaAngleX:0];
//        id flipX1 = [CCOrbitCamera actionWithDuration:1.3 radius:1 deltaRadius:0 angleZ:-180 deltaAngleZ:-360 angleX:0 deltaAngleX:0];
        CCSequence *rotSeq = [CCSequence actions:flipX,  nil];
        [iconSprite runAction:[CCRepeatForever actionWithAction:rotSeq]];

	}
	return self;
}

// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
	// in case you have something to dealloc, do it in this method
	// in this particular example nothing needs to be released.
	// cocos2d will automatically release all the children (Label)
	
	// don't forget to call "super dealloc"
	[super dealloc];
}


@end
